/* eslint valid-jsdoc: "off" */
// 正式环境
'use strict';
const path = require('path');
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  config.multipart = {
    mode: 'file',
    fileSize: '50mb', // 接收文件大小
    whitelist: [
      // 允许接收的文件类型
      '.png',
      '.jpg',
      'jpeg',
    ],
  };

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1620907179607_4201';
  // 在此处添加中间件配置
  config.middleware = ['auth'];

  // add your middleware config here
  // 配置指定的前端地址
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
    // 下面这条加上才能共享跨域session，同时前端ajax请求也要加上响应的参数
    // credentials: true,
  };
  config.security = {
    // 关闭csrf验证
    csrf: false,
    // 白名单
    domainWhiteList: ['*'],
  };
  // 正式环境日志写入路径
  config.logger = {
    level: 'INFO',
    dir: path.join(__dirname, '../logs/prod'),
  };
  // 连接mongodb的配置
  config.mongoose = {
    client: {
      url: 'mongodb://0.0.0.0:27017/develop', // 正式环境
      options: {
        auth: { authSource: 'admin' },
        user: 'root',
        pass: 'delb001',
        useNewUrlParser: true,
        useUnifiedTopology: true,
      },
    },
  };
  // 生成token的秘钥
  config.jwt = {
    secret: 'ml920226',
  };
  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
